<template>
  <div ref="editor"></div>
</template>

<script>
import E from 'wangeditor'

export default {
  props: {
    value: String
  },

  data () {
    return {
      isUploading: false,
      percentage: 0
    }
  },

  mounted () {
    this.initEditor()
  },

  methods: {
    initEditor () {
      const editor = new E(this.$refs.editor)
      editor.config.onchange = (newHtml) => {
        console.log('change 之后最新的 html', newHtml)
        this.$emit('input', newHtml)
      }
      editor.create()
      editor.txt.html(this.value)
    }
  }
}
</script>

<style lang='scss' scoped>
.avatar-uploader ::v-deep.el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader ::v-deep.el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
